import React, { useState, useEffect } from "react"

export default function HookCounterChangeTitle() {
  const [counter, setCounter] = useState(0);

  useEffect(() => {
    debugger
    console.log('副作用产生');
    document.title = counter
    return () => {
      console.log('11111');
    }
  })

  return (
    <>
      <h2>
        当前计数: {counter}
      </h2>
      <button onClick={e => setCounter(counter + 1)}>+1</button>
    </>
  )
}